#include <bits/stdc++.h>
#define sc(x) scanf("%d", &(x))
#define pr(x) printf("%d\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 1e3 + 7;
const int mod = 1e9 + 7;
vector<int> h[N], res;
int fa[N], num[N];
int Find(int x) {
    if (fa[x] != x) return Find(fa[x]);
    return x;
}
void merge(int x, int y) {
    x = Find(x);
    y = Find(y);
    fa[y] = x;
    num[x] += num[y];
}
int main() {
    int n, x, len;
    sc(n);
    rep(i, 1, n) {
        scanf("%d:", &len);
        rep(_, 1, len) sc(x), h[x].push_back(i);
    }
    rep(i, 1, n) fa[i] = i, num[i] = 1;
    rep(i, 1, 1000) {
        if (!h[i].empty()) {
            int f = h[i].front();
            for (int &x : h[i])
                if (x != f) merge(f, x);
        }
    }
    rep(i, 1, n) if (Find(i) == i) res.push_back(num[i]);
    sort(res.rbegin(), res.rend());
    int sz = res.size();
    printf("%d\n", sz);
    rep(i, 0, sz - 1) printf("%d%c", res[i], i == sz - 1 ? '\n' : ' ');
    return 0;
}